// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ArmPositionDisplayModel.cs" company="Microsoft Corporation">
// The MIT License (MIT)
// 
// Copyright (c) 2014, Microsoft Corporation
// 
// Permission is hereby granted, free of charge, to any person obtaining a copy
//  of this software and associated documentation files (the "Software"), to deal
//  in the Software without restriction, including without limitation the rights
//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//  copies of the Software, and to permit persons to whom the Software is
//  furnished to do so, subject to the following conditions:
// 
// The above copyright notice and this permission notice shall be included in
//  all copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
//  THE SOFTWARE.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------
namespace Microsoft.Robotics.Manipulation.Visualization
{
    using System;
    using System.Collections.Generic;
    using System.Collections.ObjectModel;
    using System.Windows.Controls;
    using Microsoft.Robotics.Numerics;
    using Microsoft.Robotics.Visualization;

    /// <summary>
    /// Model for simple manipulation display
    /// </summary>
    public class ArmPositionDisplayModel : Model
    {
        /// <summary>
        /// Initializes a new instance of the ArmPositionDisplayModel class
        /// </summary>
        public ArmPositionDisplayModel()
        {
            this.CartesianPositions = new Dictionary<string, Pose>();
            this.CartesianPositionNames = new ObservableCollection<string>();
            this.JointPositions = new Dictionary<string, double[]>();
            this.JointPositionNames = new ObservableCollection<string>();
        }

        /// <summary>
        /// Gets or sets names of positions
        /// </summary>
        public ObservableCollection<string> CartesianPositionNames { get; set; }

        /// <summary>
        /// Gets or sets dictionary holding the saved cartesian positions
        /// </summary>
        public Dictionary<string, Pose> CartesianPositions { get; set; }
       
        /// <summary>
        /// Gets or sets the name of the current cartesian position
        /// </summary>
        public string CurrentCartesianPositionName { get; set; }

        /// <summary>
        /// Gets or sets the current cartesian position
        /// </summary>
        public string CurrentCartesianPosition { get; set; }

        /// <summary>
        /// Gets or sets the current cartesian orientation
        /// </summary>
        public string CurrentCartesianOrientation { get; set; }

        /// <summary>
        /// Gets or sets names of positions
        /// </summary>
        public ObservableCollection<string> JointPositionNames { get; set; }

        /// <summary>
        /// Gets or sets dictionary holding the saved joint positions
        /// </summary>
        public Dictionary<string, double[]> JointPositions { get; set; }
        
        /// <summary>
        /// Gets or sets the name of the currently selected cartesian position from the list box
        /// </summary>
        public string CurrentlySelectedJointPositionName { get; set; }

        /// <summary>
        /// Gets or sets the current joint position name in the "Add/Update" checkbox.
        /// </summary>
        public string CurrentJointPositionName { get; set; }
 
        /// <summary>
        /// Gets or sets the current cartesian orientation as axis angle
        /// </summary>
        public string CurrentAxisAngle { get; set; }

        /// <summary>
        /// Gets or sets the manual entry for cartesian position
        /// </summary>
        public string CartesianPositionManual { get; set; }

        /// <summary>
        /// Gets or sets the manual entry for cartesian position
        /// </summary>
        public string CartesianOrientationManual { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether manual Cartesian update is required
        /// </summary>
        public bool DoCartesianManualUpdate { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether to go to home position
        /// </summary>
        public bool DoGoToHome { get; set; }

        /// <summary>
        /// Gets or sets a value indicating the joint speed for homing.
        /// </summary>
        public double GoToHomeSpeed { get; set; }

        /// <summary>
        /// Gets or sets the target cartesian position
        /// </summary>
        public string TargetCartesianPosition { get; set; }

        /// <summary>
        /// Gets or sets the target cartesian position
        /// </summary>
        public string TargetCartesianOrientation { get; set; }

        /// <summary>
        /// Gets or sets the name of the currently selected cartesian position from the list box
        /// </summary>
        public string CurrentlySelectedCartesianPositionName { get; set; }

        /// <summary>
        /// Gets or sets the text in the torque threshold text box
        /// </summary>
        public string TouchForceThresholdText { get; set; }

        /// <summary>
        /// Gets or sets the text in the max lin speed text box
        /// </summary>
        public string TouchMaxLinSpeedText { get; set; }

        /// <summary>
        /// Gets or sets the text in the max rot speed text box
        /// </summary>
        public string TouchMaxRotSpeedText { get; set; }

        /// <summary>
        /// Gets or sets the current joint position
        /// </summary>
        public string CurrentJointPosition { get; set; }

        /// <summary>
        /// Gets or sets the current joint velocity
        /// </summary>
        public string CurrentJointVelocity { get; set; }

        /// <summary>
        /// Gets or sets the target joint position
        /// </summary>
        public string TargetJointPosition { get; set; }

        /// <summary>
        /// Gets or sets the current - target joint difference
        /// </summary>
        public string DeltaJointPosition { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether cartesian should be updated from the manual entered list
        /// </summary>
        public bool DoCartesianUpdate { get; set; }

        /// <summary>
        /// Gets or sets the manual cartesian entry text box
        /// </summary>
        public string JointManualEntry { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether Joint should be updated from the manual entered list
        /// </summary>
        public bool DoJointUpdate { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether the position list should be updated using the current position name
        /// and arm position
        /// </summary>
        public bool DoUpdatePosition { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether the position list should be updated using the current position name
        /// and arm position
        /// </summary>
        public bool DoAddUpdateJointPosition { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether the arm should be moved to the current position
        /// </summary>
        public bool DoGoToPosition { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether the arm should be moved to the current position
        /// </summary>
        public bool DoGoToJointPosition { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether the arm should be moved to the current position
        /// using a 1 segment cubic spline
        /// </summary>
        public bool DoGoToSplineJointPosition { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether to save the current positions
        /// </summary>
        public bool SaveCartesianPositions { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether to load new positions
        /// </summary>
        public bool LoadCartesianPositions { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether to save the current positions
        /// </summary>
        public bool SaveJointPositions { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether to load new positions
        /// </summary>
        public bool LoadJointPositions { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether to touch currently selected position
        /// </summary>
        public bool DoTouchPosition { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether to move to the candle position
        /// </summary>
        public bool MoveToCandlePosition { get; set; }

        /// <summary>
        /// Gets or sets force threshold along push axis
        /// </summary>
        public string PushAxisForceThresholdText { get; set; }

        /// <summary>
        /// Gets or sets force threshold in plane perpendicular to push axis
        /// </summary>
        public string PushResidualAxisForceThresholdText { get; set; }

        /// <summary>
        /// Gets or sets X component of push axis in TCP frame
        /// </summary>
        public string PushAxisXText { get; set; }

        /// <summary>
        /// Gets or sets Y component of push axis in TCP frame 
        /// </summary>
        public string PushAxisYText { get; set; }

        /// <summary>
        /// Gets or sets Z component of push axis in TCP frame
        /// </summary>
        public string PushAxisZText { get; set; }

        /// <summary>
        /// Gets or sets maximum linear push speed
        /// </summary>
        public string PushMaxLinSpeedText { get; set; }

        /// <summary>
        /// Gets or sets maximum rotational push speed
        /// </summary>
        public string PushMaxRotSpeedText { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether to execute a push to the currently selected position
        /// </summary>
        public bool DoPushPosition { get; set; }

        /// <summary>
        /// Gets or sets points in the current spline
        /// </summary>
        public ObservableCollection<Tuple<string, double>> ExtendedSplinePoints { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether to execute the extend spline as constructed in the UI
        /// </summary>
        public bool DoExecuteExtendedSpline { get; set; }
    }
}
